//
//  HeaderView.m
//  MMLOOK
//
//  Created by dllo on 15/9/29.
//  Copyright © 2015年 武俊娥. All rights reserved.
//

#import "HeaderView.h"

@interface HeaderView ()

@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UILabel *label;

@end

@implementation HeaderView

- (void)dealloc
{
    [_image release];
    [_text release];
    [_imageView release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupViews];
    }
    return self;
}

- (void)setupViews
{
    self.imageView = [[UIImageView alloc] init];
    [self addSubview:_imageView];
    [_imageView release];
    
    self.label = [[UILabel alloc] init];
    _label.textColor = [UIColor orangeColor];
    [self addSubview:_label];
    [_label release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(10, 5, self.frame.size.height - 10, self.frame.size.height - 10);
    self.label.frame = CGRectMake(_imageView.frame.origin.x + _imageView.frame.size.width + 10, _imageView.frame.origin.y, 100, _imageView.frame.size.height);
}

- (void)setImage:(NSString *)image
{
    if (_image != image) {
        
        [_image release];
        _image = [image retain];
    }
    
    _imageView.image = [UIImage imageNamed:_image];
}

- (void)setText:(NSString *)text
{
    if (_text != text) {
        
        [_text release];
        _text = [text retain];
    }
    
    _label.text = _text
    ;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
